﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Vds2465Telegrams;

namespace Vds2465Parser
{
    public class GeneratorParser : IGeneratorParser
    {
        #region IGeneratorParser

        public byte[] GenerateTelegramBytes(Telegram telegram)
        {
            if (telegram is Telegram_Calling)
            {
                Telegram_Calling telegramCalling = telegram as Telegram_Calling;
                return GeneratorParser_Helper.GenerateTelegramBytes_Calling(telegramCalling);
            }

            if (telegram is Telegram_Returning)
            {
                Telegram_Returning telegramReturning = telegram as Telegram_Returning;
                return GeneratorParser_Helper.GenerateTelegramBytes_Returning(telegramReturning);
            }

			// TODO handle error
            return null;
        }

        public Telegram ParseTelegramBytes(byte[] telegramBytes)
        {
            return GeneratorParser_Helper.ParseTelegramBytes(telegramBytes);
        }

        #endregion IGeneratorParser     
    }
}
